 <template>
  <div class="RatingStar">
    <section class="star-container">
      <svg class="grey_fill" v-for="num in 5" :key="num">
        <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#star"></use>
      </svg>
    </section>
    <div :style="'width:' + value*2/5 + 'rem'" class="star_overflow">
      <section class="star-container">
        <svg class="orange_fill" v-for="num in 5" :key="num">
          <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#star"></use>
        </svg>
      </section>
    </div>
    <span class="text" v-if="textEnabled">{{value}}</span>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  mounted() {},
  props: ['value', 'textEnabled']
};
</script>

<style lang="scss">
@import '../styles/mixin';
.RatingStar {
  position: relative;
  top: 0.2rem;
  @include wh(2rem, 0.4rem);
  .star_overflow {
    overflow: hidden;
    position: relative;
    height: 100%;
  }
  .star-container {
    position: absolute;
    display: flex;
    width: 2rem;
    height: 0.4rem;
    top: -0.02rem;
    left: -0.02rem;
    .grey_fill {
      fill: #d1d1d1;
    }
    .orange_fill {
      fill: #ff9a0d;
    }
  }
  .text {
    position: absolute;
    top: -0.17rem;
    right: -0.9rem;
    color: #ff9a0d;
    font-size: 0.6rem;
  }
}
</style>
